import { useSelector, useDispatch } from "react-redux"
import { useCallback } from "react";
import TotalTypeApi from "../api/totalType";
import Creater from "../store/actions"

//子类hoock
export const useAssType = () => {

    const dispatch = useDispatch();
    const { ChildAll, TotalAll, assType } = useSelector(state => state.ass_type)

    const getassType = useCallback(async () => {
        const data = await TotalTypeApi.getassType();

        dispatch(Creater.getAssType({ data }));

    }, [dispatch]);

    const addAssTypeToReducer=useCallback((data)=>{
        dispatch(Creater.getAssType({ data }));
    },[dispatch])



    return [{
        ChildAll,
        TotalAll,
        assType
    }, { getassType,addAssTypeToReducer}]
}